package mutsumimod.cards.copy;

import basemod.AutoAdd;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.util.CardStats;
import mutsumimod.util.CardUtils;
import mutsumimod.util.tags.CustomTags;

import java.util.ArrayList;

@AutoAdd.Ignore
public class Imagination extends BaseCard {
    public static final String ID = makeID(Imagination.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.SKILL,
            CardRarity.COMMON,
            CardTarget.SELF,
            0
    );

    public Imagination() {
        super(ID, info);
        setAttr(0,0,2);
        setAttrUpg(0,0,0);
        originShouldCopyUse = true;
        setShouldCopyUse(true);
        tags.add(CustomTags.SELF_CARD);
        exhaust=true;
    }

    public Imagination(CardRarity rarity) {
        this();
        this.rarity = rarity;
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {

    }

    @Override
    public void beforeCopy(){
        clearCopyCards();
        ArrayList<AbstractCard> cards=CardUtils.getUnRepeatableRandomCards(magicNumber,this.rarity,new Imagination());
        if(upgraded){
            for(AbstractCard c:cards){
                c.upgrade();
            }
        }
        addCopyCards(cards);
    }

    @Override
    public AbstractCard makeCopy() { //Optional
        return new Imagination();
    }

    @Override
    public Imagination makeStatEquivalentCopy() {
        Imagination imagination = (Imagination) super.makeStatEquivalentCopy();
        imagination.rarity = rarity;
        return imagination;
    }

    public void upgradeRarity(){
        rarity = CardUtils.getNextCardRarity(rarity);
    }

    @Override
    public void updateDescription() {
        if(upgraded){
            rawDescription=cardStrings.UPGRADE_DESCRIPTION;
        }else{
            rawDescription=cardStrings.DESCRIPTION;
        }
        initializeDescription();
    }
}